import React from 'react';
import { RobotInfo, Order } from '../../types';

interface StatisticsProps {
  robots: RobotInfo[];
  idleRobotCount: number;
  completedOrders: Order[];
  aliveTime: number;
  averageConsumedTime:number;
}

export function Statistics({ robots, idleRobotCount, completedOrders,aliveTime,averageConsumedTime }: StatisticsProps) {

  return (
    <div className="bg-white p-4 rounded-lg shadow-md">
      <h2 className="text-xl font-bold mb-4">系统统计</h2>
      <div className="grid grid-cols-2 gap-4">
        <div className="p-3 bg-gray-50 rounded-md">
          <p className="text-sm text-gray-500">运行时间</p>
          <p className="text-2xl font-bold">{aliveTime}s</p>
        </div>
        <div className="p-3 bg-gray-50 rounded-md">
          <p className="text-sm text-gray-500">已完成订单</p>
          <p className="text-2xl font-bold">{completedOrders.length}</p>
        </div>
        <div className="p-3 bg-gray-50 rounded-md">
          <p className="text-sm text-gray-500">平均配送时间</p>
          <p className="text-2xl font-bold">{averageConsumedTime.toFixed(1)}s</p>
        </div>
        <div className="p-3 bg-gray-50 rounded-md">
          <p className="text-sm text-gray-500">空闲机器人</p>
          <p className="text-2xl font-bold">
            {idleRobotCount}/{robots.length == 1? (0): robots.length}
          </p>
        </div>
      </div>
    </div>
  );
}